{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "2a258575",
   "metadata": {},
   "source": [
    "## 元组(tuple)\n",
    "\n",
    "> 1. 它是和list几乎完全一样的序列数据\n",
    "> 2. 它与list不同的地方是，**不可变** （因为不可变，所以几乎没有方法）\n",
    "> 3. 元组的形式：（1，2，3，4，5）对比 元组（） 列表 []\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "7e983eff",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "10001,10002,10003 <class 'str'>\n"
     ]
    }
   ],
   "source": [
    "stu_id = \"10001,10002,10003\"\n",
    "print(stu_id,type(stu_id))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "8a923110",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stu_id.count(\"10001\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "fb69e3c9",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "6"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stu_id.index(\"10002\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "15e233c4",
   "metadata": {},
   "outputs": [
    {
     "ename": "NameError",
     "evalue": "name 'time' is not defined",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mNameError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-4-c5058db20bc1>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mhelp\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mtime\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[1;31mNameError\u001b[0m: name 'time' is not defined"
     ]
    }
   ],
   "source": [
    "help(time)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a44037f8",
   "metadata": {},
   "source": [
    "## 字典\n",
    "> 1.创建字典的三种常见方法\n",
    ">> 1. 直接按照字典的格式创捷：{ke1y:value1,key2:value2,...}\n",
    ">> 2. dict()函数来创建字典：dict(key1=value1,key2=value2,...)\n",
    ">> 3. 字典数据增加的方式：新建空字典\n",
    "> 2.字典的性质"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "379e00c8",
   "metadata": {},
   "outputs": [
    {
     "ename": "NameError",
     "evalue": "name 'stud_info' is not defined",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mNameError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-6-eb8f5bed0345>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[0;32m      5\u001b[0m     \u001b[1;34m\"stud_10003\"\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;34m\"Marry\"\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      6\u001b[0m }\n\u001b[1;32m----> 7\u001b[1;33m \u001b[0mstud_info\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[1;31mNameError\u001b[0m: name 'stud_info' is not defined"
     ]
    }
   ],
   "source": [
    "# 1. 直接按照字典的格式创捷：{ke1y:value1,key2:value2,...}\n",
    "stu_info = {\n",
    "    \"stud_10001\":\"Alex\",\n",
    "    \"stud_10002\":\"Jack\",\n",
    "    \"stud_10003\":\"Marry\"\n",
    "}\n",
    "stud_info"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "1e20480d",
   "metadata": {},
   "outputs": [
    {
     "ename": "SyntaxError",
     "evalue": "invalid syntax (<ipython-input-7-6689a63db573>, line 3)",
     "output_type": "error",
     "traceback": [
      "\u001b[1;36m  File \u001b[1;32m\"<ipython-input-7-6689a63db573>\"\u001b[1;36m, line \u001b[1;32m3\u001b[0m\n\u001b[1;33m    stud_10001:\"Alex\",\u001b[0m\n\u001b[1;37m              ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m invalid syntax\n"
     ]
    }
   ],
   "source": [
    "# 2. dict()函数来创建字典：dict(key1=value1,key2=value2,...)\n",
    "stud_info_02 = dict(\n",
    "    stud_10001:\"Alex\",\n",
    "    stud_10002:\"Jack\",\n",
    "    stud_10003:\"Marry,\n",
    ")\n",
    "stud_info_02"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "f84e6549",
   "metadata": {},
   "outputs": [],
   "source": [
    "stud_info_03 = {}\n",
    "stud_info_03[\"stud_10001\"]=\"Alex\"\n",
    "stud_info_03[\"stud_10002\"]=\"Jack\"\n",
    "stud_info_03[\"stud_10003\"]=\"Marry\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "91ce32c2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'stud_10001': 'Alex', 'stud_10002': 'Jack', 'stud_10003': 'Marry'}"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stud_info_03"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "f82e391d",
   "metadata": {},
   "outputs": [],
   "source": [
    "info = {\n",
    "    \"stu_1801\":\"ziqi\",\n",
    "    \"stu_1802\":\"xiaofeng\",\n",
    "    \"stu_1803\":\"liuyu\"\n",
    "}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "3c11de99",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'stu_1801': 'ziqi', 'stu_1802': 'xiaofeng', 'stu_1803': 'liuyu'}"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "info"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "7b30a631",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "stu_1801\n",
      "stu_1802\n",
      "stu_1803\n"
     ]
    }
   ],
   "source": [
    "for i in info:\n",
    "    print(i)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "b0293b20",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
